{include file="public/header" title="账户提现"/}
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">账户提现</h1>
    <!--<a href="" class="mui-btn-link mui-pull-right">明细</a>-->
</header>

<div class="mui-content" id="my_withdrawals">

    <form class="layui-form" action="">
        <div class="os">
            <h4>提现金额</h4>
            <div class="money-btn">
                <span>￥</span>
                <input type="number" id="moneys" name="money" class="layui-input">
            </div>
            <p>可用余额&emsp;{:number_format($user['money'],2)} <span data-money="{$user['money']}"
                                                                  onclick="alls(this)">全部提现</span></p>
        </div>
        <div class="os-btn">
            <button class="layui-btn layui-btn-danger" lay-submit lay-filter="tixian">2小时内到账，确认提现</button>
        </div>
    </form>

</div>
<script>
    (function ($) {
        $.init({
            swipeBack: true //启用右滑关闭功能
        });
    })(mui);
    var $ = layui.$, form = layui.form;
    /**
     * 提交提现
     */
    form.on('submit(tixian)', function (data) {
        var param = data.field;
        if (!param.money) {
            //$('#moneys').focus();
            mui.toast('请输入提现金额', {duration: 3000, type: 'div'});
            return false;
        }
        if (!/^\d+(\.\d{1,2})?$/.test(param.money)) {
            //$('#moneys').focus();
            mui.toast('请输入有效的金额', {duration: 3000, type: 'div'});
            return false;
        }
        param.money = parseFloat(param.money);
        console.log(param);
        mui.toast('提现成功', {duration: 3000, type: 'div'});
        setTimeout(function () {
            location.href = "{:url('my_money')}";
        }, 3000);
        return false;
    });

    /**
     * 选择全部提现
     * @param obj
     */
    function alls(obj) {
        $('#moneys').val(parseFloat($(obj).data('money')));
    }
</script>
{include file="public/footer"/}